﻿using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Graphics;

using HMEngine.HMCameras;
using HMEngine.HMEffects;
using HMEngine.HMInputs;
using HMEngine.HMObjects;

namespace HMEngine {
    public class HMGame : Game {
        private readonly GraphicsDeviceManager myGraphics;

        public HMGame() {
            myGraphics = new GraphicsDeviceManager(this);
            Components.Add(new HMObjectManager(this));
            Components.Add(new HMCameraManager(this));
            Components.Add(new HMInputManager(this));
            Components.Add(new HMEffectManager(this));

            Window.AllowUserResizing = true;
            Window.ClientSizeChanged += Window_ClientSizeChanged;
        }

        void Window_ClientSizeChanged(object sender, System.EventArgs e) {
            myGraphics.PreferredBackBufferWidth = Window.ClientBounds.Width;
            myGraphics.PreferredBackBufferHeight = Window.ClientBounds.Height;
            HMCameraManager.ActiveCamera.SetViewport(GraphicsDevice.Viewport);
        }

        public void ToggleFullScreen() {
            myGraphics.ToggleFullScreen();
        }

        protected override void Draw(GameTime gameTime) {
            GraphicsDevice.Clear(Color.Black);
            base.Draw(gameTime);
        }
    }
}